<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>#{msg.carrelloTitle1}</title>
        <style>
          
        </style>
    </h:head>
    <h:body>
        <div class="container">
            #{carrelloManager.setCarrello(gestioneCliente)}
            #{spesaM.setRedirect(redirect)}
            #{spesaM.setCarrello(carrelloManager)}
            #{spesaM.setCliente(gestioneCliente)}
            <ui:include src="Header.xhtml"/>
            <div class="content">
                <h3><p:outputLabel value="#{msg.carrelloTitle}"/></h3>
                <p:growl autoUpdate="true"/>
                <h:form id="form">
                    <p:dataTable id="table" value="#{spesaM.prodottiCarrello()}" var="p" style="text-align: center;" emptyMessage="#{msg.carrelloEmpty}">
                        <f:facet name="header">
                            <p:outputLabel value="#{msg.carrelloHeader}"/>
                        </f:facet>
                        <p:column headerText="#{msg.immageTable}">
                            <p:graphicImage value="#{p.foto.fotoPath()}" width="100" height="80"/>
                        </p:column>
                        <p:column headerText="#{msg.nomeTable}">
                            <p:outputLabel value="#{p.nome}"/>
                        </p:column>
                        <p:column headerText="#{msg.prezzoTable}">
                            <h:outputFormat value="#{spesaM.prezzoProdotto(p)}">
                                <f:convertNumber minFractionDigits="2" maxFractionDigits="2"/>
                            </h:outputFormat> €
                        </p:column>
                        <p:column headerText="#{msg.quantitaTable}">
                            <p:outputLabel value="#{spesaM.getQuantitaNelCarrello(p)}"/>
                        </p:column>
                        <p:column headerText="#{msg.opTable}">
                            <p:commandButton icon="ui-icon-plus" update=":form" actionListener="#{spesaM.riaggiungiProdotto(p)}"/>
                            <p:commandButton icon="ui-icon-minus" update=":form" actionListener="#{spesaM.rimuoviUnProdotto(p)}"/>
                            <p:commandButton icon="ui-icon-exp" update=":form" actionListener="#{spesaM.rimuoviProdotto(p)}"/>
                        </p:column>
                        <f:facet name="footer">
                           #{msg.subTotaleFormat} <h:outputFormat value="#{carrelloManager.subTotale}">
                               <f:convertNumber minFractionDigits="2" maxFractionDigits="2"/>
                           </h:outputFormat> €<br/><hr/>
                           <p:commandButton actionListener="#{spesaM.svuotaCarrello()}" update=":form" value="#{msg.svuotaCarrelloLabel}" icon="ui-icon-exp"/>
                        </f:facet>
                    </p:dataTable>
                    <hr/>
                    <p:outputLabel value="#{msg.resCarrello}"/>
                    <h:panelGrid style="margin-top: 20px;" columns="2">
                        
                        <p:outputLabel value="#{msg.subTotaleFormat}"/> 
                        <h:outputFormat value="#{carrelloManager.subTotale}" style="text-align: right;">
                            <f:convertNumber minFractionDigits="2" maxFractionDigits="2"/>
                        </h:outputFormat>
                        
                        <p:outputLabel value="#{msg.speseSpedizioneLabel}"/>
                        <h:outputFormat value="#{spesaM.speseSpedizione.prezzo}" style="text-align: right;">
                            <f:convertNumber maxFractionDigits="2" minFractionDigits="2"/>
                        </h:outputFormat>
                        
                        <p:outputLabel value="#{msg.totaleTable}:" style="color: green;"/>
                        <h:outputFormat value="#{spesaM.totale}" style="color:green;">
                            <f:convertNumber maxFractionDigits="2" minFractionDigits="2"/>
                        </h:outputFormat>
                        
                    </h:panelGrid>
                    <p style="margin-top: 20px;">
                        <p:commandButton action="#{spesaM.indietroDaCarrello()}" style="margin-right: 700px;" value="#{msg.indietroLable}"/> 
                        <p:commandButton id="ordineButton" action="#{spesaM.ordina()}" disabled="#{carrelloManager.isEmpty()}" value="#{msg.ordinaLabel}"/>
                    </p>
                </h:form>
            </div>
            <ui:include src="Footer.xhtml"/>
        </div>
    </h:body>
</html>

